package com.lixw.saa.controller;

import com.lixw.saa.records.StudentRecord;
import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: StructuredOutputController
 * @Description:
 * @Author: xuweiLi
 * @Create: 2025/10/3 13:13
 **/
@RestController
public class StructuredOutputController {
    @Resource(name = "qwenChatClient")
    private ChatClient qwenChatClient;

    @GetMapping("/structuredoutput/chat")
    public StudentRecord chat(@RequestParam("sname") String sname,@RequestParam("email") String email) {
        StudentRecord entity = qwenChatClient.prompt()
                .user(promptUserSpec -> {
                    promptUserSpec.text("学号1001,我叫{sname},大学专业是计算机科学与技术,邮箱{email}")
                            .param("sname", sname)
                            .param("email", email);
                }).call().entity(StudentRecord.class);
        return entity;
    }
}